package cn.hzking.gjmall.view;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Typeface;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.util.AttributeSet;

import cn.hzking.gjmall.R;

/**
 * Created by Administrator on 2018/2/6.
 */

public class TypefaceTextView extends android.support.v7.widget.AppCompatTextView {

    public TypefaceTextView(Context context) {
        super(context);
        init(context, null);
    }

    public TypefaceTextView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        init(context, attrs);
    }

    private void init(Context context, AttributeSet attrs) {
        TypedArray mArray = context.obtainStyledAttributes(attrs, R.styleable.TypefaceTextView);
        String mTypefacePath = mArray.getString(R.styleable.TypefaceTextView_typefacePath);
        mArray.recycle();
        if (!TextUtils.isEmpty(mTypefacePath) ) {
            setTypeface(Typeface.createFromAsset(context.getAssets(), mTypefacePath));
        }
    }


}
